<template>
    <div>
        <el-menu
                :default-active="currentPath"
                router
                mode="horizontal"
                background-color="white"
                text-color="#222"
                active-text-color="red"
                style="min-width: 1300px">
            <el-menu-item v-for="(item,i) in navList" :key="i" :index="item.name">
                {{ item.navItem }}
            </el-menu-item>
<!--      size="medium"      -->
            <span style="position: absolute;padding-top: 20px;right: 43%;font-size: 20px;font-weight: bold">White Jotter - Your Mind Palace</span>
            <el-input
                    placeholder="快速搜索..."
                    prefix-icon="el-icon-search"

                    style="width: 300px;position:absolute;margin-top: 12px;right: 18%"
                    v-model="keywords">
            </el-input>
        </el-menu>
    </div>
</template>

<script>
    import {computed, getCurrentInstance, reactive, toRefs} from "vue";

    export default {
        name: 'NavMenu',
        setup() {
            const data = reactive({
                navList: [
                    {name: '/index', navItem: '首页'},
                    {name: '/jotter', navItem: '笔记本'},
                    {name: '/library', navItem: '图书馆'},
                    {name: '/login', navItem: '管理中心'}
                ],
                keywords: ''
            })
            let {proxy} = getCurrentInstance();
            let hoverBackground = computed(() => {
                return '#ffd04b'
            })
            let currentPath = computed(() => {
                let x = proxy.$route.path.indexOf('/', 1)
                if (x !== -1) {
                    return proxy.$route.path.substring(0, x)
                } else {
                    return proxy.$route.path
                }
            })
            return {
                ...toRefs(data),
                hoverBackground,
                currentPath,

            }
        }


    }
</script>

<style scoped>
    a {
        text-decoration: none;
    }

    span {
        pointer-events: none;
    }

</style>
